
public class booleanSchedule {
	
	private final int numSlots = 56;

	private boolean schedule[] = new boolean[numSlots];
	
	public booleanSchedule()
	{
		for (int count=0; count < numSlots; count++)
		{
			schedule[count] = false;
		}
	}
	
	public boolean getAvailable(int slot)
	{
		return schedule[slot];
	}
	public void setAvailable(int slot)
	{
		schedule[slot] = true;
	}
	public void setUnavailable(int slot)
	{
		schedule[slot] = false;
	}
public void setMilTimeSchedUnavailable(int startTime, int endTime)
    {
        	milTimeSchedule temp = new milTimeSchedule();
        	int startTimeSlot;
        	int endTimeSlot;
        	startTime = temp.getStart(startTime);
        	endTime = temp.getEnd(endTime);
        	startTimeSlot = temp.milTimeToSlot(startTime);
        	endTimeSlot = temp.milTimeToSlot(endTime);
        	schedule[startTimeSlot] = false;
        	schedule[endTimeSlot] = false;
       }
	//Make sure to put check in to keep start time and end time valid
	
	//creates boolSchedule for one day based on milTimeSchedule
	public void generateSchedule(milTimeSchedule newSchedule)
	{
		int slotCount = newSchedule.getNumSlots();
		//loops through each set slot, one created each time .setAvailable() is called
		for (int i=0;i<slotCount;i++){					
			int startTime = newSchedule.getStart(i);			
			int endTime = newSchedule.getEnd(i);
			int startMin = newSchedule.convertToMin(startTime);
			int endMin = newSchedule.convertToMin(endTime);
			//System.out.println("generateSchedule startTime = " +startTime + " endtime = " + endTime + " start Min = " + startMin + " endMin = " + endMin);
			for (int count = startMin/15; count<endMin/15; count++){
				schedule[count] = true;
			}
		}
	}
	public int convertSlotToMil(int slot){
		int startTime = (slot*15)+480;
		int startMin = startTime%60;
		int startTimeHour = (startTime-startMin)/60;
		startTimeHour = startTimeHour*100;
		startTime = startTimeHour + startMin;
		return startTime;
	}
	public milTimeSchedule getMilTimeSchedule(int newMinMeetTime)
	{
		int index = 0;
		int startTime, endTime, timeDiff;
		int minMeetTime = newMinMeetTime;
		milTimeSchedule m = new milTimeSchedule();
		while(index<numSlots){
			System.out.println("index is " + index);
			while (index < numSlots && schedule[index] == false)
			{
				index++;
			}			
			if (index >= numSlots) return m;
			
			startTime = convertSlotToMil(index);
			System.out.println("start time is " + startTime);
			while(index < numSlots && schedule[index] == true)
			{
				index++;
			}
			
			if (index >= numSlots)
			{
				endTime = convertSlotToMil(numSlots);
			}
			else
			{
			   endTime = convertSlotToMil(index);
			}
			System.out.println("end time is " + endTime);
			timeDiff = m.convertToMin(endTime) - m.convertToMin(startTime);
			System.out.println("timeDiff is " + timeDiff);
			if(timeDiff>=minMeetTime){
				m.setAvailable(startTime, endTime);
			}else{
				System.out.println(timeDiff + "less than min meeting time");
			}
		}
		return m;

	}
	//Defaults minMeetTime to 30
	public milTimeSchedule getMilTimeSchedule(){
		return getMilTimeSchedule(30);
	}
	
}
